{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}

{% block main %}
    <div class="ec-role">
        <div class="ec-pageHeader">
            <h1>{{ 'front.shopping.shipping_title'|trans }}</h1>
        </div>
    </div>

    <div class="ec-registerRole">
        <div class="ec-off1Grid">
            <div class="ec-off1Grid__cell">
                <div class="ec-addressRole">
                    {% if Customer.CustomerAddresses|length < eccube_config.eccube_deliv_addr_max %}
                        <div class="ec-addressRole__actions"><a class="ec-inlineBtn" href="{{ url('shopping_shipping_edit', {'id': shippingId}) }}">{{ 'front.shopping.shipping_add_new_shipping'|trans }}</a></div>
                    {% else %}
                        <div class="ec-alert-warning">
                            <div class="ec-alert-warning__text">
                                <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
                                {{ 'common.customer_address_count_is_over'|trans({ '%count%': eccube_config.eccube_deliv_addr_max }) }}
                            </div>
                        </div>
                    {% endif %}
                    {% if has_errors(form.addresses) %}
                        <div class="ec-alert-warning">
                            <div class="ec-alert-warning__text">
                                <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
                                {{ 'front.shopping.shipping_unselected'|trans }}
                            </div>
                        </div>
                    {% endif %}
                </div>

                <form method="post" action="{{ url('shopping_shipping', {'id': shippingId}) }}">
                    {{ form_widget(form._token) }}
                    <div class="ec-addressList">
                        {% for choice in form.addresses.vars.choices %}
                            {% set Address = choice.data %}
                        <div class="ec-addressList__item">
                            <div class="ec-addressList__remove">
                                {% set checked = choice is selectedchoice(form.addresses.vars.value) ? 'checked="checked"' : '' %}
                                <input type="radio" id="address{{ choice.value }}" name="{{ form.addresses.vars.full_name }}" value="{{ choice.value }}" {{ checked }} />
                            </div>
                            <div class="ec-addressList__address">
                                <div>{{ Address.name01 }}&nbsp;{{ Address.name02 }}</div>
                                <div>〒{{ Address.postal_code }} {{ Address.Pref }}{{ Address.addr01 }}{{ Address.addr02 }}</div>
                                <div>{{ Address.phone_number }}</div>
                            </div>
                        </div>
                        {% endfor %}
                    </div>

                    <div class="ec-registerRole__actions">
                        <div class="ec-off4Grid">
                            <div class="ec-off4Grid__cell">
                                <button type="submit" class="ec-blockBtn--action">{{ 'front.shopping.shipping_send_selected_shipping'|trans }}</button>
                                <a class="ec-blockBtn--cancel" href="{{ url('shopping') }}">{{ 'common.back'|trans }}</a>
                            </div>
                        </div>
                    </div>

                </form>
            </div>
        </div>

    </div>
{% endblock %}
